//package com.ruijie.config;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.config.annotation.web.builders.WebSecurity;
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
//import org.springframework.security.crypto.password.PasswordEncoder;
//import org.springframework.security.web.authentication.www.DigestAuthenticationEntryPoint;
//import org.springframework.security.web.authentication.www.DigestAuthenticationFilter;
//
//@Configuration
//@EnableWebSecurity
//public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
//
//	@Override
//	public void configure(WebSecurity web) throws Exception {
//		web.ignoring().antMatchers("/css/**");
//		web.ignoring().antMatchers("/js/**");
//	}
//
//	@Bean
//	public DigestAuthenticationEntryPoint digestEntryPoint() {
//		DigestAuthenticationEntryPoint digestAuthenticationEntryPoint = new DigestAuthenticationEntryPoint() {
//
//		};
//		digestAuthenticationEntryPoint.setKey("acegi");
//		digestAuthenticationEntryPoint.setNonceValiditySeconds(30 * 60);
//		digestAuthenticationEntryPoint
//				.setRealmName("Contacts Realm via Digest Authentication");
//		return digestAuthenticationEntryPoint;
//	}
//
//	@Autowired
//	DigestAuthenticationEntryPoint digestAuthenticationEntryPoint;
//
//	@Bean
//	public DigestAuthenticationFilter digestAuthenticationFilter(
//			DigestAuthenticationEntryPoint digestAuthenticationEntryPoint)
//			throws Exception {
//		DigestAuthenticationFilter digestAuthenticationFilter = new DigestAuthenticationFilter();
//		digestAuthenticationFilter
//				.setAuthenticationEntryPoint(digestEntryPoint());
//		digestAuthenticationFilter.setUserDetailsService(super
//				.userDetailsServiceBean());
//		return digestAuthenticationFilter;
//	}
//	
////	public void configure(AuthenticationManagerBuilder auth)
////			throws Exception {
////		
////		auth.inMemoryAuthentication().withUser("123").password("123")
////				.authorities("ROLE_USER").and().withUser("admin")
////				.password("123456").authorities("ROLE_USER", "ROLE_ADMIN");
////	}
//	
//
//	@Autowired
//	PasswordEncoder passwordEncoder;
//
//	@Bean
//	public PasswordEncoder passwordEncoder() {
//		return new BCryptPasswordEncoder(5);
//	}
//	
//	public void configureGlobal(AuthenticationManagerBuilder auth)
//			throws Exception {
//		//digest not support
//		auth.inMemoryAuthentication()
//				.passwordEncoder(passwordEncoder)
//				.withUser("admin")
//				// 123456
//				.password("$2a$05$uYs.4IMu07yj68Oy9KRWoOEHOos2WIFUNk5bg5eGRRhWF/n2Skmwq")
//				.roles("ADMIN");
//	}
//
//	@Override
//	protected void configure(HttpSecurity http) throws Exception {
//		 http
//		 .authorizeRequests()
//		 .antMatchers("/", "/index").permitAll()
//		 .anyRequest().authenticated()
//		 .and()
//		 .formLogin()
//		 .loginPage("/login")
//		 .permitAll()
//		 .and()
//		 .logout()
//		 .deleteCookies("remove")
//		 .invalidateHttpSession(true)
//		 .logoutUrl("/logout")
//		 .logoutSuccessUrl("/");
//
////		http.sessionManagement()
////				.sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
////				.authorizeRequests().antMatchers("/html/**").authenticated()
////				.and().exceptionHandling()
////				.authenticationEntryPoint(digestAuthenticationEntryPoint);
////		http.csrf().disable();
////		http.addFilter(digestAuthenticationFilter(digestAuthenticationEntryPoint));
//		// http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.ALWAYS);
//		 
//		// http
//		// .authorizeRequests()
//		// .antMatchers("/", "/index","/resources/**", "/html/*").permitAll()
//		// .anyRequest().authenticated()
//		// .and()
//		// .httpBasic();
//	}
//}